﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

namespace SSISFromCode
{

    internal class OBJECT_CREATION
    {
        public const string FLATFILE_CONNECTION = "FLATFILE";
        public const string OLEDB_CONNECTION = "OLEDB";
        //public const string EXCEL = "EXCEL";
        public const string DATA_FLOW_TASK = "STOCK:PipelineTask";  // PipelineTask is a DataFlowTask ??
        public const string FLAT_FILE_SOURCE = "Flat File Source";
        //public const string EXCEL_SOURCE = "Excel Source";
        public const string EXCEL_SOURCE = "OLE DB Source";
        public const string XML_SOURCE = "XML Source";
        public const string SQL_SERVER_DEST = "SQL Server Destination";
        public const string EXECUTE_SQL_TASK = "STOCK:SQLTask";
        public const string DATA_CONVERSION = "Data Conversion";
        public const string DERIVED_COLUMN = "Derived Column";
    }

    internal class COMPONENT_PROPERTY_NAMES
    {
        public const string TABLE_NAME = "BulkInsertTableName";
        public const string TIMEOUT = "Timeout";
        public const string WORKSHEET = "OpenRowset";
        public const string XML_FILE = "XMLData";
        public const string XML_SCHEMA_FILE = "XMLSchemaDefinition";
        public const string FRIENDLY_EXPRESSION = "FriendlyExpression";
        public const string EXPRESSION = "Expression";
        public const string LENGTH = "length";
        public const string SOURCE_LINEAGE_ID = "SourceInputColumnLineageID";
    }

    internal class COMMON_PROPERTY_NAMES
    {
        public const string NAME = "Name";
        public const string CONNECTION_STR = "ConnectionString";
    }

    internal class COMPONENT_NAMES
    {
        public const string FLAT_FILE_CONNECTION = "Flat File Connection";
        public const string OLEDB_CONNECTION = "OLE DB Connection";
        public const string EXCEL_CONNECTION = "Excel ACE Connection";
        public const string DATA_CONVERSION = "Data Conversion";
        public const string DERIVED_COLUMN = "Derived Column";
    }

    internal class FLAT_FILE_PROPERTY_NAMES
    {
        public const string FORMAT = "Format";
        public const string COLUMN_NAMES_FIRST_ROW = "ColumnNamesInFirstDataRow";
        public const string HEADER_ROW_DELIMITER = "HeaderRowDelimiter";
        public const string ROW_DELIMITER = "RowDelimiter";
        public const string QUALIFIER = "TextQualifier";
        public const string DATA_ROWS_TO_SKIP = "DataRowsToSkip";
    }

    internal class OLEDB_PROPERTY_NAMES
    {
        public const string RETAIN_SAME_CONNECTION = "RetainSameConnection";
    }

    internal class DESTINATION_TABLE
    {
        public const string CREATE_TABLE = "create TABLE [dbo].[{0}]({1})";
        public const string TABLE_NAME = "##{0}";
        public const string CREATE_PRIMARY_KEY_COLUMN = "[{0}] int primary key IDENTITY(1,1),";
        public const string CREATE_COLUMN = "[{0}] [varchar]({1}) NULL";  // uses CHAR_WIDTH below
        public const int CHAR_WIDTH = 1375;
        public const string NAME = "[tempdb].[dbo].[{0}]";
    }

    internal class DELIMITERS
    {
        /// In a flat file connection, if you set the delimiter to "{CR}{LF}", it'll look correct if you open the resulting package in the UI, but it won't execute (unless you click "Reset Columns")
        public const string NEWLINE = "\r\n";
        public const char COMMA = ',';
    }

    /// <summary>
    /// Connection manager property uses this
    /// </summary>
    internal class FORMAT
    {
        public const string DELIMITED = "Delimited";
        public const string FIXED_WIDTH_MANAGER = "RaggedRight";
    }

    /// <summary>
    /// Relies on this driver: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=13255
    /// Don't use JET; no 64 bit version
    /// </summary>
    internal class EXCEL_CONNECTION_STRINGS
    {
        public const string XLSX_EXTENSION = ".XLSX";
        public const string XLSX = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"EXCEL 12.0;HDR={1}\"";
        public const string XLS = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"EXCEL 8.0;HDR={1}\"";
    }

    internal class IMPORT_MESSAGES
    {
        public const string INFORMATION = "{0}, Information: {1}";
        public const string PROGRESS = "{0}, {1}, Percent Complete: {2}";
        public const string WARNING = "{0}, Warning: {1}";
        public const string ERROR = "{0}, Error: {1}";
        public const string FAILURE = "{0} Failed";
        public const string COL_WIDTH_LOW_THRESHOLD = "{0}, Warning: Column count is so high that each column width is less than {1}"; // 1 is replaced with COL_WIDTH_LOW_THRESHOLD below
    }

    internal class MISC
    {
        public const string QUOTE_QUALIFIER = "\"";
        public const int ANSI_LATIN_1 = 1252;
        public const DataType DEST_DATA_TYPE = DataType.DT_STR;  // DT_TEXT was for varchar(max)
        public const string CAINT_DETERMINE_XML_COLS = "Unable to determine columns for XML file.  XML may not be well formed.";
        public const string TRIM_EXPRESSION = "({0},{1},{2})RTRIM({3})";
        /// <summary>
        /// Here's how this number was arrived at:
        /// First, see comment in TransformationGeneratorHelper.ColumnWidth.
        /// Tests proved that the more columns you have, the less length you can configure each column.
        /// E.g.:
        /// - 127 columns X 3000 fails
        /// - 127 columns X 2000 works
        /// - 254 columns X 1500 fails (same result as first test case with double columns; halved lengths)
        /// - 254 columns X 1375 works: this is our constant below
        /// </summary>
        public const int MAX_ROW_LENGTH_NON_FLAT_FILE = 347875;
        public const int COL_WIDTH_LOW_THRESHOLD = 100;
    }

}